package com.gt.andr.multbl;

import com.gt.andr.R;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

/**
 * 
 * @author Ganesh
 * 
 */

public class MultiplicationTableMainActivity extends Activity {

	Button incButton, decButton;
	EditText ipNumberTxt;
	TextView outputTXT;
	MultiplicationListener mulListener;
	MultiplicationTableButtonClickListener incListener;
	MultiplicationTableButtonClickListener decListener;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);

		// get resources
		incButton = (Button) findViewById(R.id.incButton);
		decButton = (Button) findViewById(R.id.decButton);
		ipNumberTxt = (EditText) findViewById(R.id.inputNumber);
		outputTXT = (TextView) findViewById(R.id.outputTXT);
		// TextWatcher listener
		mulListener = new MultiplicationListener(outputTXT, ipNumberTxt);
		ipNumberTxt.addTextChangedListener(mulListener);
		// TextWatcher works after changing value in onClickListeners
		incListener = new MultiplicationTableButtonClickListener(ipNumberTxt, true);
		decListener = new MultiplicationTableButtonClickListener(ipNumberTxt, false);
		incButton.setOnClickListener(incListener);
		decButton.setOnClickListener(decListener);
	}
}